package com.demo.dao.impl;

import com.demo.dao.UserDao;
import com.demo.pojo.User;

import java.util.List;

/**
 * @author wzm
 * @create 2023-05-04 10:09
 */
public class UserDaoImpl extends BaseDao implements UserDao {
    @Override
    public User selectByUserAndPassWord(User user) {
        String sql = "select * from user where username = ? and password = ?";
        return selectForOne(User.class,sql,user.getUsername(),user.getPassword());
    }

    @Override
    public int insert(User user) {
        String sql ="insert into user(username,password) values(?,?)";
        return update(sql,user.getUsername(),user.getPassword());
    }

    @Override
    public int delete(User user) {
        return 0;
    }

    @Override
    public List<User> selectByLikeName(User user) {
        String sql ="select * from user where username like ?";
        //return selectForList(User.class,sql,"%"+user.getUsername()+"%");
        return selectForList(User.class,sql,user.getUsername());
    }
}
